package com.treasure.mall.biz.entity.auction;

import com.treasure.mall.biz.entity.Base2PO;
import com.treasure.mall.biz.entity.user.UserPO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * 出价记录
 *
 * @author allan
 * @version 1.0.0
 * @date 2020/7/16
 */
@Entity
@Table(name = "zb_auction_bid_log")
@Setter
@Getter
@NoArgsConstructor
@Cacheable(false)
public class AuctionBidLogPO extends Base2PO {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;
    /**
     * 出价人
     */
    @ManyToOne
    @JoinColumn(name = "rel_user_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
    private UserPO userPO;
    /**
     * 拍卖id
     */
    @Column(name = "rel_session_id")
    private Long sessionId;
    /**
     * 出价金额
     */
    @Column(name = "bid_amount")
    private BigDecimal bidAmount;

    public AuctionBidLogPO(AuctionBidPO bidPO) {
        this.userPO = bidPO.getUserPO();
        this.sessionId = bidPO.getSessionPO().getId();
        this.bidAmount = bidPO.getBidAmount();
    }
}
